<?php
/**
 * Created by PhpStorm.
 * User: xzk
 * Date: 2021/6/9
 * Time: 9:42
 */
namespace App\Http\Admin\Controllers\Config;
use App\Http\Controllers\Controller;
use Hlcreation\Basic\Helper;
use Illuminate\Http\Request;
use App\Requests\UploadRequest;

use App\Services\config\UploadServices;

class UploadController extends Controller
{


    public function __construct(UploadServices $services)
    {
        $this->services = $services;
    }

    /**
     *  阿里云上传配置
     * */

    //添加存储配置   1 是阿里云上传配置   2 是腾讯云上传配置  3是囚牛云上传配置
    public function fileAdd(UploadRequest $request){

        $all = $request->all();
        $userInfo = Helper::getPost('userinfo');
        $all['creator_uid'] = $userInfo['user_info']['id'];  //创建者
        $all['created_at'] = date("Y-m-d H:i:s");


        $data = $this->services->UploadAliSave($all);
        if($data){
            if(($all['status'])) return Helper::toJson("配置成功", 200);
            else  return Helper::toJson("关闭成功", 200);

        }else{
            return Helper::toJson("配置失败", 400);
        }
    }








    //查看阿里云信息   1 是阿里云上传配置   2 是腾讯云上传配置  3是囚牛云上传配置
    public function fileInfo(Request $request){

        $userInfo = Helper::getPost('userinfo');

        $uid = $userInfo['user_info']['id'];  //创建者

        $type = $request->only('type');

        $data = $this->services->fileInfos($uid,$type);


        return  Helper::toJson('文件上传配置详情 ',200,$data);

    }



##########################################################################################################################










}
